package com.beehoo.dcportal.admin.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.beehoo.dcportal.admin.dao.WorkerDao;
import com.beehoo.dcportal.admin.service.WorkerService;
import com.beehoo.dcportal.common.base.BaseException;
import com.beehoo.dcportal.common.base.BaseService;
import com.beehoo.dcportal.model.FunctionBean;
import com.beehoo.dcportal.model.WorkerBean;
import com.beehoo.dcportal.utils.CommonUtils;

public class WorkerServiceImpl extends BaseService implements WorkerService {

	private WorkerDao workerDao;

	public void setWorkerDao(WorkerDao workerDao) {
		this.workerDao = workerDao;
	}

	@Override
	public WorkerBean queryUserByNP(String loginName, String password)
			throws BaseException {
		if(CommonUtils.nvlToString(loginName).equals("")){
			throw new BaseException("custom.messages.error.user.name.empty");
		}
		if(CommonUtils.nvlToString(password).equals("")){
			throw new BaseException("custom.messages.error.user.pwd.empty");
		}
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("loginName", loginName);
		paramMap.put("password", password);
		return workerDao.queryUserByNP(paramMap);
	}

	@Override
	public List<FunctionBean> queryFunction(String roleId) throws BaseException {
		if(CommonUtils.nvlToString(roleId).equals("")){
			throw new BaseException("custom.messages.error.user.role.empty");
		}
		return workerDao.queryFunction(roleId);
	}

}
